package com.wn32.main.demo8;

public class Company extends Thread {
    private static int num=100;

    public Company(String name){
        this.setName(name);
    }

    @Override
    public void run() {
        while (true){
            try {
                employ();
                Thread.sleep(1200);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    public static Object obj=new Object();
    public void employ() throws InterruptedException {
        synchronized (obj) {
            obj.notify();
            obj.wait();
            System.out.println(Thread.currentThread().getName() + ":成功招收" + num + "号学员");
            num--;
        }
    }
}
